package com.web.util;

import org.springframework.core.io.InputStreamResource;
import java.io.IOException;
import java.io.InputStream;

/**
 * 支持 MultipartFile 转 RestTemplate 上传的工具类
 */
public class MultipartInputStreamFileResource extends InputStreamResource {

    private final String filename;

    public MultipartInputStreamFileResource(InputStream inputStream, String filename) {
        super(inputStream);
        this.filename = filename;
    }

    @Override
    public String getFilename() {
        return this.filename;
    }

    @Override
    public long contentLength() throws IOException {
        return -1; // 我们不知道内容长度
    }
}
